package com.fr.report;

import com.fr.base.core.FT;
import com.fr.report.core.DynamicValueList;
import com.fr.report.core.ReportHelper;
import com.fr.report.core.ReportUtils;
import java.awt.Dimension;
import java.util.Iterator;

public class SheetPage extends ReportPage
{
  public SheetPage(Report paramReport)
  {
    super(paramReport, new PageInfo(1), null, new FT[] { new FT(0, paramReport.getRowCount()) }, new FT[] { new FT(0, paramReport.getColumnCount()) }, 0, 0);
  }

  private PaperSize getPaperSize()
  {
    PaperSize localPaperSize = new PaperSize(0.0D, 0.0D);
    DynamicValueList localDynamicValueList1 = ReportHelper.getColumnWidthList(this.source_report);
    DynamicValueList localDynamicValueList2 = ReportHelper.getRowHeightList(this.source_report);
    int i = Math.max(localDynamicValueList1.getRangeValueFromZero(this.source_report.getColumnCount()), 1);
    int j = Math.max(localDynamicValueList2.getRangeValueFromZero(this.source_report.getRowCount()), 1);
    Iterator localIterator = this.source_report.floatIterator();
    while (localIterator.hasNext())
    {
      localObject = (FloatElement)localIterator.next();
      int k = localDynamicValueList1.getRangeValueFromZero(((FloatElement)localObject).getColumn()) + ((FloatElement)localObject).getLeftDistance();
      int l = localDynamicValueList2.getRangeValueFromZero(((FloatElement)localObject).getRow()) + ((FloatElement)localObject).getTopDistance();
      int i1 = ((FloatElement)localObject).getSize().width + 1;
      int i2 = ((FloatElement)localObject).getSize().height + 1;
      i = Math.max(i, k + i1);
      j = Math.max(j, l + i2);
    }
    Object localObject = new PaperSetting(getReportSettings().getPaperSize(), getReportSettings().getMargin(), getReportSettings().getOrientation());
    localPaperSize.setWidth(i + ReportUtils.getMarginLeft((PaperSetting)localObject) + ReportUtils.getMarginRight((PaperSetting)localObject));
    localPaperSize.setHeight(j + ReportUtils.getMarginTop((PaperSetting)localObject) + ReportUtils.getMarginBottom((PaperSetting)localObject) + ReportUtils.getFooterHeight(getReportSettings()) + ReportUtils.getHeaderHeight(getReportSettings()));
    return ((PaperSize)localPaperSize);
  }

  public int getPageWidth()
  {
    return (int)getPaperSize().getWidth();
  }

  public int getPageHeight()
  {
    return (int)getPaperSize().getHeight();
  }
}